package proseus.app.meet;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PersonListAdapter extends BaseAdapter {
	int m_layout;
	LayoutInflater m_inflater;
	ArrayList<PersonListItem> m_items;

	public PersonListAdapter(Context context, int layout, ArrayList<PersonListItem> items) {
		m_layout = layout;
		m_inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		m_items = items;
	}

	@Override
	public int getCount() {
		return m_items.size();
	}

	@Override
	public Object getItem(int index) {
		return m_items.get(index).m_name;
	}

	@Override
	public long getItemId(int index) {
		return index;
	}

	@Override
	public View getView(int index, View view, ViewGroup parent) {
		if (view == null) {
			view = m_inflater.inflate(m_layout, parent, false);
		}

		TextView tvName = (TextView) view.findViewById(R.id.tvName);
		tvName.setText(m_items.get(index).m_name + " " + m_items.get(index).m_pos);

		TextView tvOrg = (TextView) view.findViewById(R.id.tvOrg);
		tvOrg.setText(m_items.get(index).m_org);

		return view;
	}
}
